#pragma once
#include <string>
#include <list>
#include "Time.h"
#include "SongInfo.h"

using namespace std;

class LastFMTrack {
    public:
        /// The artist name.
        wstring artist;
        /// The track name.
        wstring track;
        /// The time the track started playing, in UNIX timestamp format (integer number of seconds since 00:00:00, January 1st 1970 UTC). This must be in the UTC time zone.
        uint64_t timestamp;
        /// The album name.
        wstring album;
        /// The stream id for this track received from the radio.getPlaylist service, if scrobbling Last.fm radio
        wstring streamId;
        /// Set to 1 if the user chose this song, or 0 if the song was chosen by someone else (such as a radio station or recommendation service). Assumes 1 if not specified
        bool chosenByUser = true;
        /// The track number of the track on the album.
        uint16_t trackNumber;
        /// The MusicBrainz Track ID.
        wstring mbid;
        /// The album artist - if this differs from the track artist.
        wstring albumArtist;
        /// The length of the track in seconds.
        Time duration;
        void Clear();
        void SaveDataTo(CArchive &archive);
        void ReadDataFrom(CArchive &archive);
        void ReadDataFrom(SongInfo info);
        bool operator==(const LastFMTrack& track);
        bool operator==(const SongInfo& info);
};

class LastFMDataArchive {
public:
    /// The origin track information of current track.
    LastFMTrack current_track;
    /// The track information of current track after corrected.
    LastFMTrack corrected_current_track;
    /// The list of tracks are not scrobbed.
    list<LastFMTrack> cached_tracks;
    /// A session key generated by authenticating a user via the authentication protocol.
    wstring session_key;
    /// User name
    wstring user_name;
    /// The played time for current song in millisecond.
    int32_t current_played_time;
    /// The current song is pushed to cache list or not.
    bool is_pushed;
    void SaveData(wstring path);
    void LoadData(wstring path);
};
